from time import*

def sort_nums(data):
    flag = 1
    while flag:
        flag = 0
        for i in range(len(data) - 1):
            if data[i] > data[i + 1]:
                data[i], data[i + 1] = data[i + 1], data[i]
                flag = 1
        
def read_f(file):
    data = [int(i) for i in open(file)]
    return data

step_1 = read_f("m1_sorted .txt")
step_2 = read_f("m2_reverse .txt")
step_3 = read_f("m3_shuffle .txt")
# применить для других файлов
# сделать проверку циклической
time_start1 = time()
sort_nums(step_1)
time_finish1 = time()
time_start2 = time()
sort_nums(step_2)
time_finish2 = time()
time_start3 = time()
sort_nums(step_3)
time_finish3 = time()

print(f'm1_sorted {int((time_finish1-time_start1)*1000)} milliseconds')
print(f'm2_reverse {int((time_finish2-time_start2)*1000)} milliseconds')
print(f'm3_shuffle {int((time_finish3-time_start3)*1000)} milliseconds')
# Опубликовать проект на hub.mos.ru
